package com.rv.admin.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.rv.admin.domain.Room;
import com.rv.admin.service.IRoomService;
import com.rv.common.core.domain.R;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/room")
public class RoomController {

    @Resource
    private IRoomService roomService;

    @PostMapping("/create")
    public R<Long> createRoom(@RequestBody Room room) {
        return roomService.createRoom(room);
    }

    @GetMapping("/public")
    public R<Page<Room>> queryPublicRoomList(Page<Room> page, Room room) {
        return roomService.queryPublicRoomList(page, room);
    }

    @GetMapping("/owner")
    public R<Page<Room>> queryOwnerRoomList(Page<Room> page, Room room) {
        return roomService.queryOwnerRoomList(page, room);
    }

    @GetMapping("/{roomId}/query")
    public R<Room> queryRoomById(@PathVariable Long roomId) {
        return roomService.queryRoomById(roomId);
    }


    @PostMapping("/{roomId}/dismiss")
    public R<Boolean> dismissRoom(@PathVariable Long roomId){
        return roomService.dismissRoom(roomId);
    }

    @PostMapping("/edit")
    public R<Boolean> editRoom(@RequestBody Room room){
        return roomService.editRoom(room);
    }

    @PostMapping("/verify")
    public R<Boolean> verifyPassword(@RequestBody Room room){
        return roomService.verifyPassword(room);
    }
}
